#include "jniheader/com_FKASGradle_MainActivity.h"
#include "lua.hpp"

lua_State* state=0;

void JNICALL Java_com_FKASGradle_MainActivity_initlua(JNIEnv *, jobject){
    if(!state)state=luaL_newstate();
}

void JNICALL Java_com_FKASGradle_MainActivity_freelua(JNIEnv *, jobject){
    if(state)lua_close(state),state=0;
}

jstring JNICALL Java_com_FKASGradle_MainActivity_hello(JNIEnv *env, jobject, jstring s){
    jboolean isCopy;
    luaL_dostring(state,env->GetStringUTFChars(s, &isCopy));
    return env->NewStringUTF(lua_tostring(state,-1));
}